{include file='common/head' /}
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
              <a><cite>商品管理</cite></a>
              <a><cite>商品首页功能菜单</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <!--按钮和功能-->
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="xadmin.open('添加商品首页功能菜单','/admin/product/functionMenuEdit',800,600)"><i class="layui-icon"></i>添加</button>
                    <span style="line-height:40px;float: right;">共有数据：{$count} 条</span>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th style="text-align: center;">名称</th>
                            <th style="text-align: center;">图片</th>
                            <th style="text-align: center;">跳转地址</th>
                            <th style="text-align: center;">是否显示</th>
                            <th style="text-align: center;">操作时间</th>
                            <th style="text-align: center;">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="v"}
                        <tr>
                            <td style="text-align: center;">{$v.name}</td>
                            <td style="text-align: center;"><img style="width:200px;cursor: pointer;" alt="图片地址错误" src="{$v.img}" title="带我预览图片" onclick="lookImg('{$v.img}','-首页功能菜单-{$v.name}')"/></td>
                            <td style="text-align: center;">{$v.page}</td>
                            <td style="text-align: center;">
                                {$v.status == 1 ?
                                '<button type="button" class="layui-btn layui-btn-normal layui-btn-xs"><i class="layui-icon ">&#xe605;</i></button>' :
                                '<button type="button" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#x1006;</i></button>';
                                }
                            </td>
                            <td style="text-align: center;">{:date('Y-m-d H:i:s',$v['add_time'])}</td>
                            <td style="text-align: center;" class="td-manage">
                                <button class="layui-btn layui-btn layui-btn-xs" title="编辑"  onclick="xadmin.open('编辑','/admin/product/functionMenuEdit?id={$v.id}',800,600)" href="javascript:;">
                                    <i class="layui-icon">&#xe642;</i>编辑
                                </button>
                                <button class="layui-btn-danger layui-btn layui-btn-xs" title="删除" onclick="del(this,{$v['id']})" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i>删除
                                </button>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form','laydate'], function(){
        var  form = layui.form;
        var laydate  = layui.laydate;
        //执行一个laydate实例
        laydate.render({
              elem: '#start' //指定元素
          });

        // 监听全选
        // form.on('checkbox(checkall)', function(data){
        //     if(data.elem.checked){
        //         $('tbody input').prop('checked',true);
        //     }else{
        //         $('tbody input').prop('checked',false);
        //     }
        //     form.render('checkbox');
        // });
    });

    /*删除*/
    function del(obj,id){
        layer.confirm('确认要删除吗？',{icon: 8,title: '提示'},function(index){
            $.ajax({
                url:"{:url('Product/functionMenuDel')}",
                type: "post",
                data:{id:id},
                dataType:"json",
                success:function (res) {
                    if(res.code == 200){
                        layer.msg('删除成功', {icon: 1,time:1000});
                        $(obj).parents("tr").remove();
                    }else{
                        layer.alert(res.msg, {icon:2,time:1000});
                    }
                },
                error:function(e){
                    layer.alert("网络错误", {icon:5,time:1000});
                }
            });
        },function(){
            layer.msg('取消成功', {icon: 6,time:1000});
        });
    }
</script>
{include file='common/scroll' /}
{include file='common/footer' /}